﻿#pragma once

//实现vtk渲染窗口的功能
#include <vtkActor.h>
#include <vtkActorCollection.h>
#include <vtkAreaPicker.h>
#include <vtkCallbackCommand.h>
#include <vtkCellPicker.h>
#include <vtkCommand.h>
#include <vtkInteractorStyleTrackballCamera.h>
#include <vtkMath.h>
#include <vtkObjectFactory.h>
#include <vtkPolyData.h>
#include <vtkPolyDataMapper.h>
#include <vtkProperty.h>
#include <vtkRenderer.h>
#include <vtkRenderWindow.h>
#include <vtkRenderWindowInteractor.h>
#include <vtkSmartPointer.h>
#include <vtkSphereSource.h>
#include <vtkCubeSource.h>
#include <vtkCylinderSource.h>
#include <vtkOutlineFilter.h>
#include <vtkSetGet.h>
#include <vtkObjectFactory.h>


#include "SelectionManager.h"
#include "ActorManager.h"

//继承vtkInteractorStyle类，实现自定义的功能
// 自定义交互样式
class MyVtkInteractorSelect: public vtkInteractorStyleTrackballCamera
{
public:
    static MyVtkInteractorSelect* New();

    MyVtkInteractorSelect();
    ~MyVtkInteractorSelect();

    virtual void OnLeftButtonDown() override;
    virtual void OnMouseMove() override;

    void SetMultiPickMode(bool enable);
    bool GetMultiPickMode();

    void SetPickMode(PickMode mode);
    std::shared_ptr<SelectionManager> GetSelectionManagerManager() const;
    void SetSelectionChangedCallback(std::function<void()> callback);// 设置选择更改回调
    void SelectActor(vtkActor* actor, bool addToSelection = false);   // 通过程序选择Actor


private:
    void Pick();
    void Hover();
    std::function<void()> SelectionChangedCallback;

    std::shared_ptr<SelectionManager> m_SelectionManager = nullptr;
    std::shared_ptr<SelectionManager> m_HoverManager = nullptr;
    std::shared_ptr<ActorManager> m_ActorManager = nullptr;
    vtkSmartPointer<vtkCellPicker> m_CellPicker = nullptr;
    bool m_MultiPickMode = false;
    PickMode m_CurrentPickMode = PickMode::VOLUME;

};